// const uniID = require('uni-id-common')
const Dysmsapi20170525 = require('@alicloud/dysmsapi20170525');
const OpenApi = require('@alicloud/openapi-client');
const Util = require('@alicloud/tea-util');
const Tea = require('@alicloud/tea-typescript');

function createClient() {
	let config = new OpenApi.Config({
		// 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
		accessKeyId: 'LTAI5tNsuVvTgF3kwFbwKbaN',
		// 必填，请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
		accessKeySecret: "kZBBDPbmy7YPd5bh28YG0hXKVnjOkk",
	});
	// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
	config.endpoint = `dysmsapi.aliyuncs.com`;
	return new Dysmsapi20170525.default(config);
}
module.exports = async function(params = {}) {
	let errorMsg=null
	let res
	

	let client = createClient();
	let sendSmsRequest = new Dysmsapi20170525.SendSmsRequest({
		phoneNumbers: '17701250598',
		signName: '海洲通科技',
		templateCode: 'SMS_472345384',
		templateParam: '{"code":"564388"}',
	});
	let runtime = new Util.RuntimeOptions({});
	try {
		// 复制代码运行请自行打印 API 的返回值
		res=await client.sendSmsWithOptions(sendSmsRequest, runtime);
		
	} catch (error) {
		// 此处仅做打印展示，请谨慎对待异常处理，在工程项目中切勿直接忽略异常。
		// 错误 message
		// console.log(error.message);
		errorMsg=error.message
		// 诊断地址
		// console.log(error.data["Recommend"]);
		// Util.default.assertAsString(error.message);
	}

	return {
		errCode: 0,
		errMsg: 'test-ali-sms-success',
		errorMsg,
		res
	}
}